﻿using System.Linq;
using ConfigurationManagement.Data;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using ConfigurationManagement.MsBuild.Tests.TaskTests;

namespace ConfigurationManagement.MsBuild.Tests
{
    [TestClass]
    [DeploymentItem("ConfigurationManagement.Data.dll")]
    [DeploymentItem("ConfigurationManagement.MsBuild.dll")]
    public class MsBuildTasksTests : MsBuildTest
    {
        [TestInitialize]
        public void Setup()
        {
            GetFileAndWriteToPath("ConfigurationManagement.MsBuild.Tests.MsBuild.proj", "MsBuild.proj");
            GetFileAndWriteToPath("ConfigurationManagement.MsBuild.Tests.TestInput.txt", "TestInput.txt");
            GetFileAndWriteToPath("ConfigurationManagement.MsBuild.Tests.FileBasedDictionary.xml",
                                       "ConfigureFileBasedOndictionary.FileBasedDictionary.xml");

            TestUtilities.CleanAuditData();
            TestUtilities.RemoveBasicTestData();
            TestUtilities.AddBasicTestData();
            TestUtilities.SetupAuditData();
        }
        [TestCleanup]
        public void TearDown()
        {
            TestUtilities.CleanAuditData();
            TestUtilities.RemoveBasicTestData();
        }
       
        [TestMethod]
        public void Test()
        {
            const string args = "MsBuild.proj /t:Build";
            var result = RunMsBuild(args);
            Assert.IsTrue(result == 0, "The result was not as expected");
        }
    }
}